//
//  SetCountdownTimeCell.m
//  HaoHint
//
//  Created by winter on 16/5/24.
//  Copyright © 2016年 wd. All rights reserved.
//

#import "SetCountdownTimeCell.h"

@interface SetCountdownTimeCell ()
@property (weak, nonatomic) IBOutlet UILabel *timeLabel;

@end

@implementation SetCountdownTimeCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setTimeModel:(SetCountdownTimeCellModel *)timeModel
{
    _timeModel = timeModel;
    self.timeLabel.text = timeModel.time;
    
    self.timeLabel.textColor = timeModel.textColor;
}

@end

@implementation SetCountdownTimeCellModel

- (void)setEditTime:(BOOL)editTime
{
    _editTime = editTime;
    
    self.textColor = [UIColor colorWithHexString:editTime ? @"FF6000":@"007AFF"];
}

- (void)setTimeSecond:(NSInteger)timeSecond
{
    _timeSecond = timeSecond;
    
    NSInteger hours = timeSecond / 3600;
    NSInteger minutes = (timeSecond / 60) % 60;
    
    if (hours > 0) {
        if (minutes == 0) {
            self.time = [NSString stringWithFormat:@"%ld小时",(long)hours];
        }
        else {
            self.time = [NSString stringWithFormat:@"%ld小时%ld分钟",(long)hours,(long)minutes];
        }
    }
    else {
        self.time = [NSString stringWithFormat:@"%ld分钟",(long)minutes];
    }
    
    self.timeString = [NSString stringWithFormat:@"%.2ld:%.2ld:00",(long)hours,(long)minutes];
}
@end